package controllers.reunion;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import services.VecinoService;
import controllers.AbstractController;
import domain.Vecino;

@Controller
@RequestMapping("/reunion")
public class ReunionController extends AbstractController {

	@Autowired
	private VecinoService vecinoService;

	public ReunionController() {
		super();
	}

	@RequestMapping(value = "/asistentes", method = RequestMethod.GET)
	public ModelAndView asistentes(@RequestParam int reunionId) {
		ModelAndView result;
		Collection<Vecino> asistentes;
		Boolean asistentesView;

		asistentesView = true;
		asistentes = vecinoService.findAsistentesByReunion(reunionId);

		result = new ModelAndView("vecino/asistentes");
		result.addObject("requestURI", "vecino/list.do");
		result.addObject("vecinos", asistentes);
		result.addObject("asistentesView", asistentesView);
		result.addObject("reunionId", reunionId);

		return result;
	}
}
